#Region " Imports "

Imports System

#End Region

Partial Class Usercontrols_Gallery_MyGallery
    Inherits UserControlBase

	'#Region " Enums, Memebers and Properties "

	'    Private DataPageLocal As New PagedDataSource

	'    Public Property sortCriteria() As String
	'        Get
	'            Return CStr(ViewState("sortCriteria"))
	'        End Get

	'        Set(ByVal Value As String)
	'            ViewState("sortCriteria") = Value
	'        End Set
	'    End Property

	'    Public Property sortDir() As String
	'        Get
	'            Return CStr(ViewState("sortDir"))
	'        End Get

	'        Set(ByVal Value As String)
	'            ViewState("sortDir") = Value
	'        End Set
	'    End Property

	'    Protected Property NodeGuid() As Guid
	'        Get
	'            Return GetGuidFromVS("NodeID")
	'        End Get
	'        Set(ByVal value As Guid)
	'            ViewState.Add("NodeID", value)
	'        End Set
	'    End Property

	'    Protected Property ResourceGuid() As Guid
	'        Get
	'            Return GetGuidFromVS("ResourceID")
	'        End Get
	'        Set(ByVal value As Guid)
	'            ViewState.Add("ResourceID", value)
	'        End Set
	'    End Property

	'    Protected Property Update() As Boolean
	'        Get
	'            Return GetBooleanFromVS("Update")
	'        End Get
	'        Set(ByVal value As Boolean)
	'            ViewState.Add("Update", value)
	'        End Set
	'    End Property

	'    Private Enum GridColums
	'        Checkbox = 0
	'        Thumbnail = 1
	'    End Enum

	'    Public Property ItemGuid() As Guid
	'        Get
	'            Return GetGuidFromVS("ItemGuid")
	'        End Get
	'        Set(ByVal value As Guid)
	'            ViewState.Add("ItemGuid", value)
	'        End Set
	'    End Property

	'    Public Property HideFileSelection() As Boolean
	'        Get
	'            Return GetBooleanFromVS("HideFileSelection")
	'        End Get
	'        Set(ByVal value As Boolean)
	'            ViewState.Add("HideFileSelection", value)
	'        End Set
	'    End Property

	'    Public Property IsLoadedAsOption() As Boolean
	'        Get
	'            Return GetBooleanFromVS("IsLoadedAsOption")
	'        End Get
	'        Set(ByVal value As Boolean)
	'            ViewState.Add("IsLoadedAsOption", value)
	'        End Set
	'    End Property

	'#End Region

	'#Region " Page Events "

	'    Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
	'        Me.MessageLabel = Me.uxMessagesLabel
	'    End Sub

	'    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

	'        ScriptManager.GetCurrent(Page).RegisterPostBackControl(uxUploadFileButton)

	'        If Not IsLoadedAsOption Then
	'            SetPageTitle(Resources.Resource.MyGallery)
	'        End If

	'        If IsUserAuthenticated And (EnableUserGalleries OrElse IsGalleryModerator()) Then

	'            GetQueryStringValues()

	'            If Me.Page.IsPostBack = False Then

	'                'Set Default Sort Order and Direction
	'                Me.sortCriteria = "resourcename"
	'                Me.sortDir = "asc"

	'                PopulateRootLevel(Me.uxMyGalleryTreeView, TreeViewNodes.TreeType.UserTree, CurrentUserID)
	'                LoadPage()

	'                Me.uxCharCountLabel.Text = "250"
	'                Me.uxFileDescriptionTextBox.Attributes.Add("maxCharacters", "250")
	'                Me.uxFileDescriptionTextBox.Attributes.Add("onkeyup", "return CharacterCount(this, " & Me.uxCharCountLabel.ClientID & ");")

	'            End If

	'            ConfigBaseNavCtrls()

	'            Me.uxFileSelectionPanel.Visible = Not HideFileSelection
	'            Me.uxSaveButton.Visible = HideFileSelection
	'            Me.uxSaveButton.Enabled = HideFileSelection

	'            Me.uxMemberPanel.Visible = ShowControls(SecurityMask.Member, True)

	'        Else
	'            uxMemberPanel.Visible = False
	'            uxMessagesLabel.Text = Resources.Resource.AdminDisabledGalleries.ToString
	'        End If

	'        Me.uxSecurity.IsLoadedAsOption = True

	'    End Sub

	'#End Region

	'#Region " Save Data "

	'    Private Sub DeleteResource()
	'        'Dim AttachmentList As New StringBuilder
	'        Dim iI As Integer

	'        While iI < Me.uxResourceGalleryGridView.Rows.Count
	'            Dim Row As GridViewRow = Me.uxResourceGalleryGridView.Rows(iI)
	'            Dim Checked As Boolean = CType(Row.FindControl("uxSelectCheckBox"), CheckBox).Checked
	'            Dim ResourceGuid As New Guid(CType(Row.FindControl("uxResourceIDLabel"), Label).Text.ToString)

	'            If Checked Then
	'                ResourceDetail.DeleteResourceDetail(ResourceGuid)
	'            End If

	'            System.Math.Min(System.Threading.Interlocked.Increment(iI), iI - 1)

	'        End While

	'    End Sub

	'    Private Sub AddFolder(ByVal FolderName As String)
	'        Dim NodeItem As ResourceTreeNodeDetail = ResourceTreeNodeDetail.NewResourceTreeNodeDetail()

	'        If Not (Me.uxMyGalleryTreeView.SelectedNode Is Nothing) Then
	'            NodeItem.parentnodeid = ConvertToGuid(Me.uxMyGalleryTreeView)
	'        End If

	'        NodeItem.name = FolderName
	'        NodeItem.Userid = CurrentUserID
	'        NodeItem.Save()

	'        LoadTree()
	'    End Sub

	'#End Region

	'#Region " Load Data "

	'    Private Sub LoadPage()
	'        LoadPageSize(Me.uxPageSizeDropDownList)
	'    End Sub

	'    Private Sub LoadTree()
	'        Me.uxMyGalleryTreeView.Nodes.Clear()
	'        PopulateRootLevel(Me.uxMyGalleryTreeView, TreeViewNodes.TreeType.UserTree, CurrentUserID)
	'        Me.uxMyGalleryTreeView.ExpandAll()
	'    End Sub

	'    Public Overloads Overrides Sub BindDataItems()
	'        Dim List As New ResourceList
	'        Dim DS As New DataSet
	'        Dim DT As New DataTable
	'        Dim DV As New DataView

	'        DS = List.GetResourceListByNode(NodeGuid)

	'        Me.RecordCount = DS.Tables(0).Rows.Count

	'        DT = DS.Tables(0)

	'        DV.Table = DT

	'        DV.Sort = Me.sortCriteria & " " & Me.sortDir

	'        Me.DataPage.DataSource = DV
	'        Me.DataPage.AllowPaging = True
	'        Me.DataPage.PageSize = CType(Me.uxPageSizeDropDownList.SelectedValue.ToString, Integer)
	'        Me.DataPage.CurrentPageIndex = Me.PageNumber

	'        CreatePagingLinks()

	'        With Me.uxResourceGalleryGridView
	'            .DataSource = Me.DataPage
	'            .DataBind()
	'        End With

	'    End Sub

	'#End Region

	'#Region " Form Controls Events "

	'    Protected Sub uxTreeView_SelectedNodeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles uxMyGalleryTreeView.SelectedNodeChanged
	'        ViewState.Add("SelectedNode", Me.uxMyGalleryTreeView.SelectedValue.ToString.Trim)
	'        NodeGuid = ConvertToGuid(Me.uxMyGalleryTreeView)

	'        Me.uxUploadFileButton.Enabled = True
	'        Me.uxInfoLabel.Visible = False

	'        Me.PageNumber = 0
	'		BindDataItems()

	'		uxMyGalleryTreeView.SelectedNode.ImageUrl = String.Format("~/App_Themes/{0}/images/icons/folderopened.gif", Page.Theme)

	'		ResetNodeFolder(Me.uxMyGalleryTreeView.SelectedValue.ToString().Trim())

	'    End Sub

	'    Protected Sub uxTreeView_TreeNodePopulate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.TreeNodeEventArgs) Handles uxMyGalleryTreeView.TreeNodePopulate
	'        PopulateSubLevel(e.Node.Value.Trim, e.Node, TreeViewNodes.TreeType.UserTree, CurrentUserID)
	'    End Sub

	'    Protected Sub uxThumbnailViewCheckbox_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles uxThumbnailViewCheckbox.CheckedChanged
	'        If Me.uxThumbnailViewCheckbox.Checked = True Then
	'            Me.uxResourceGalleryGridView.Columns.Item(GridColums.Thumbnail).Visible = False
	'        Else
	'            Me.uxResourceGalleryGridView.Columns.Item(GridColums.Thumbnail).Visible = True
	'        End If
	'    End Sub

	'    Protected Sub uxDeleteButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles uxDeleteButton.Click
	'        DeleteResource()
	'        BindDataItems()
	'    End Sub

	'    Protected Sub uxResourceGalleryGridView_Sorting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewSortEventArgs) Handles uxResourceGalleryGridView.Sorting
	'        'Get the Sort by Value from the Sortexpression field on the column
	'        If Me.sortCriteria = e.SortExpression Then
	'            If Me.sortDir = "desc" Then
	'                Me.sortDir = "asc"
	'            Else
	'                Me.sortDir = "desc"
	'            End If
	'        End If

	'        ' Assign the column clicked to the sortCriteria property
	'        Me.sortCriteria = e.SortExpression

	'        'Calls the function to rebuild the datagrid view, with the new sort order
	'        BindDataItems()
	'    End Sub

	'    Protected Sub uxUploadFileButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles uxUploadFileButton.Click

	'        Dim ResourceID As Guid = Guid.Empty

	'        If Me.uxSelectFileUpload.PostedFile.ContentType.IndexOf("image/") = 0 Or _
	'            Me.uxSelectFileUpload.PostedFile.ContentType.IndexOf("video/") = 0 Or _
	'            System.IO.Path.GetExtension(Me.uxSelectFileUpload.PostedFile.FileName.ToString).ToUpper() = ".FLV" = True Or _
	'            System.IO.Path.GetExtension(Me.uxSelectFileUpload.PostedFile.FileName.ToString).ToUpper() = ".SWF" = True Or _
	'            System.IO.Path.GetExtension(Me.uxSelectFileUpload.PostedFile.FileName.ToString).ToUpper() = ".ZIP" = True Then

	'            If Update Then
	'                ResourceID = UpdateResource(Me.uxSelectFileUpload, Me.uxThumbNailFileupload, Me.uxUploadTitleTextBox.Text.Trim, Me.uxFileDescriptionTextBox.Text.Trim, ResourceGuid, UploadType.NewItem, Me.uxPrivateCheckBox.Checked)
	'            Else
	'                ResourceID = InsertResource(Me.uxSelectFileUpload, Me.uxThumbNailFileupload, Me.uxUploadTitleTextBox.Text.Trim, Me.uxFileDescriptionTextBox.Text.Trim, ConvertToGuid(Me.uxMyGalleryTreeView), UploadType.UpdateItem, Me.uxPrivateCheckBox.Checked)
	'            End If

	'            uxOptions.ItemGuid = ResourceID
	'            uxOptions.SetInitialOptions = True
	'            uxOptions.SaveOptions()
	'            uxOptions.LoadOptions()

	'            BindDataItems()
	'        Else
	'            ScriptManager.RegisterStartupScript(uxUploadFileButton, Me.GetType(), "warning", String.Format("window.alert('{0}');", Resources.Resource.OnlyFileTypes), True)
	'        End If

	'    End Sub

	'    Protected Sub uxSaveButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles uxSaveButton.Click

	'        Dim iI As Integer

	'        While iI < Me.uxResourceGalleryGridView.Rows.Count
	'            Dim Row As GridViewRow = Me.uxResourceGalleryGridView.Rows(iI)
	'            Dim Checked As Boolean = CType(Row.FindControl("uxSelectCheckBox"), CheckBox).Checked
	'            Dim ResourceGuid As New Guid(CType(Row.FindControl("uxResourceIDLabel"), Label).Text.ToString)

	'            If Checked Then
	'                Dim Item As ItemResource = ItemResource.NewItemResource()
	'                Item.Itemid = ItemGuid
	'                Item.Resourceid = ResourceGuid
	'                Item.Save()
	'            End If

	'            System.Math.Min(System.Threading.Interlocked.Increment(iI), iI - 1)

	'        End While

	'        uxAttachments.InitialLoad = False
	'        uxAttachments.ItemGuid = ItemGuid
	'        uxAttachments.BindDataItems()

	'    End Sub

	'    Protected Sub uxAddFolderImageButton_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles uxAddFolderImageButton.Click
	'        AddFolder(Me.uxNodeNameTextBox.Text.Trim)
	'    End Sub

	'    Protected Sub uxDeleteFolderImageButton_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles uxDeleteFolderImageButton.Click
	'        ResourceTreeNodeDetail.DeleteResourceTreeNodeDetail(ConvertToGuid(Me.uxMyGalleryTreeView))

	'        LoadTree()
	'    End Sub

	'    Protected Sub uxUpdateFolderImageButton_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles uxUpdateFolderImageButton.Click
	'        Dim NodeItem As ResourceTreeNodeDetail = ResourceTreeNodeDetail.GetResourceTreeNodeDetail(ConvertToGuid(Me.uxMyGalleryTreeView))

	'        NodeItem.nodeid = ConvertToGuid(Me.uxMyGalleryTreeView)
	'        NodeItem.name = Me.uxNodeNameTextBox.Text.Trim
	'        NodeItem.Save()

	'        LoadTree()
	'    End Sub

	'    Protected Sub SecureItem(ByVal sender As Object, ByVal e As CommandEventArgs)
	'        Dim Item As String() = Split(e.CommandArgument.ToString, "|")

	'        Me.uxSecurityModalPopupExtender.Show()

	'        uxSecurity.ItemGuid = ConvertToGuid(Item(0).ToString.Trim)
	'        uxSecurity.ItemName = Item(1).ToString.Trim
	'        uxSecurity.BindDataItems()
	'        uxSecurity.LoadItemName()

	'    End Sub

	'    Protected Sub ItemOptions(ByVal sender As Object, ByVal e As CommandEventArgs)

	'        Me.uxOptionsModalPopupExtender.Show()

	'        uxOptions.ItemGuid = ConvertToGuid(e.CommandArgument.ToString)
	'        uxOptions.LoadOptions()

	'    End Sub

	'    Protected Sub EditResource(ByVal sender As Object, ByVal e As CommandEventArgs)
	'        Dim Item As ResourceDetail = ResourceDetail.GetResourceDetail(ConvertToGuid(e.CommandArgument.ToString))

	'        Me.uxFileDescriptionTextBox.Text = Item.resourcedesc
	'        Me.uxUploadTitleTextBox.Text = Item.resourcetitle

	'        ResourceGuid = ConvertToGuid(e.CommandArgument.ToString)
	'        Update = True

	'    End Sub

	'    Protected Sub DeleteItem(ByVal sender As Object, ByVal e As CommandEventArgs)

	'        ResourceDetail.DeleteResourceDetail(ConvertToGuid(e.CommandArgument.ToString))
	'        BindDataItems()

	'    End Sub

	'#End Region

	'#Region " Helpers and Methods "

	'    Private Sub GetQueryStringValues()
	'        ItemGuid = GetGuidFromQueryString("id")

	'        If ItemGuid = Guid.Empty Then
	'            ItemGuid = GetGuidFromQueryString("postid")
	'        End If

	'    End Sub

	'    Private Sub ConfigBaseNavCtrls()

	'        Me.PagingTopPanel = Me.uxPagingTopPanel
	'        Me.PagingBottomPanel = Me.uxPagingBottomPanel

	'        Me.RepeaterTop = Me.uxPagesTopRepeater
	'        Me.RepeaterBottom = Me.uxPagesBottomRepeater

	'        Me.NextTopLinkButton = Me.uxTopNextLinkButton
	'        Me.PreviousTopLinkButton = Me.uxTopPrevLinkButton
	'        Me.NextBottomLinkButton = Me.uxBottomNextLinkButton
	'        Me.PreviousBottomLinkButton = Me.uxBottomPrevLinkButton

	'        Me.DataPage = DataPageLocal
	'        Me.PageSize = CType(Me.uxPageSizeDropDownList.SelectedValue.ToString, Integer)
	'        Me.PagesToDisplay = 10

	'        Me.ItemsPerPageDropDown = Me.uxPageSizeDropDownList
	'        Me.ItemsPerPageLabel = Me.uxItemsPerPageLabel
	'        Me.PagerInfoLabel = Me.uxPagerInfoLabel

	'        AddHandler Me.RepeaterTop.ItemCommand, AddressOf PagingRepeater_ItemCommand
	'        AddHandler Me.RepeaterBottom.ItemCommand, AddressOf PagingRepeater_ItemCommand

	'	End Sub

	'	Private Sub ResetNodeFolder(ByVal searchValue As String)
	'		For Each tn As TreeNode In uxMyGalleryTreeView.Nodes
	'			If tn.ChildNodes.Count > 0 Then
	'				For Each cTn As TreeNode In tn.ChildNodes
	'					ResetChildNodeFolder(cTn, searchValue)
	'				Next
	'			End If
	'		Next
	'	End Sub

	'	Private Sub ResetChildNodeFolder(ByVal tn As TreeNode, ByVal searchValue As String)
	'		If Not tn.Value = searchValue Then
	'			tn.ImageUrl = String.Format("~/App_Themes/{0}/images/icons/folder.gif", Page.Theme)
	'			Exit Sub
	'		End If

	'		If tn.ChildNodes.Count > 0 Then
	'			For Each tnC As TreeNode In tn.ChildNodes
	'				ResetChildNodeFolder(tnC, searchValue)
	'			Next
	'		End If
	'	End Sub

	'#End Region

End Class
